package gti310.tp4;

public class TableQ {

	final static double[][] MatrixQY = { { 16, 40, 40, 40, 40, 40, 49, 72 },
			{ 40, 40, 40, 40, 40, 40, 64, 92 },
			{ 40, 40, 40, 40, 40, 55, 78, 95 },
			{ 40, 40, 40, 40, 56, 64, 87, 98 },
			{ 40, 40, 40, 51, 68, 81, 103, 112 },
			{ 40, 58, 57, 87, 109, 104, 121, 100 },
			{ 51, 60, 69, 80, 103, 113, 120, 103 },
			{ 61, 55, 56, 62, 77, 92, 101, 95 } };

	final static double[][] MatrixQUV = { { 17, 40, 40, 40, 95, 95, 95, 95 },
			{ 40, 40, 40, 40, 95, 95, 95, 95 },
			{ 40, 40, 40, 95, 95, 95, 95, 95 },
			{ 40, 40, 40, 95, 95, 95, 95, 95 },
			{ 95, 95, 95, 95, 95, 95, 95, 95 },
			{ 95, 95, 95, 95, 95, 95, 95, 95 },
			{ 95, 95, 95, 95, 95, 95, 95, 95 },
			{ 95, 95, 95, 95, 95, 95, 95, 95 } };

	public static double QY(int x, int y, int fq) {
		if (fq > 0 && fq <= 50) {
			return (50 / (double) fq) * MatrixQY[x][y];
		} else if (fq > 51 && fq <= 99) {
			return ((200 - 2 * (double) fq) / 100) * MatrixQY[x][y];
		} else if (fq == 100) {
			return 1;
		} else {
			return 0;
		}
	}

	public static double QUV(int x, int y, int fq) {
		if (fq > 0 && fq <= 50) {
			return (50 / (double) fq) * MatrixQUV[x][y];
		} else if (fq > 51 && fq <= 99) {
			return ((200 - 2 * (double) fq) / 100) * MatrixQUV[x][y];
		} else if (fq == 100) {
			return 1;
		} else {
			return 0;
		}
	}

}
